package com.example.mooney.domain;

import javax.persistence.Entity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.roo.addon.entity.RooEntity;
import javax.persistence.Table;
import java.math.BigDecimal;
import javax.validation.constraints.NotNull;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import com.example.mooney.domain.Category;
import javax.persistence.ManyToOne;
import javax.persistence.JoinColumn;

@Entity
@DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING, length=1)
@RooJavaBean
@RooToString
@RooEntity
@Table(name = "TRANSACT")
public abstract class Transaction {

    private String description;

    @NotNull
    private BigDecimal amount;

    @NotNull
    @Column(name = "TRANSACT_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;

    @ManyToOne(targetEntity = Category.class)
    @JoinColumn
    private Category category;

}
